<template>
  <div>
    <el-row class="elRow" :gutter="30" type="flex" justify="start">
      <el-col :span="6">
        <span class="large">{{ $t('market.stockUnit') }}<!--库存单位--></span>
        <el-input
          v-model.trim="information.fstoreUnit"
          class="input-width"
          size="mini"
          disabled
        />
      </el-col>
      <el-col :span="6">
        <span class="large">{{ $t('market.stock2') }}<!--仓库--></span>
        <el-autocomplete
          v-model="information.fstock"
          popper-class="my-autocomplete"
          :fetch-suggestions="querySearch21"
          placeholder="请输入内容"
          size="mini"
          class="input-width"
          :disabled="detailDisabled"
          @focus="handleWarehouse"
          @select="warehouseSelectRow"
        >
          <i
            v-show="!detailDisabled"
            slot="suffix"
            class="el-input__icon el-icon-search"
            @click="openWarehouse=true"
          />
          <template slot-scope="{ item }">
            <div class="name">{{ item.fname }}</div>
          </template>
        </el-autocomplete>
      </el-col>
      <el-col :span="6">
        <span class="large">{{ $t('market.stockplace') }}<!--仓位--></span>
        <el-input
          v-model="information.fstockPlaceName"
          placeholder="请输入仓位"
          size="mini"
          class="input-width"
          :disabled="detailDisabled"
        />
      </el-col>
      <el-col :span="6">
        <span class="large">{{ $t('market.minStock') }}<!--最小库存--></span>
        <el-input
          v-model="information.fminStock"
          placeholder="请输入最小库存"
          size="mini"
          class="input-width"
          type="number"
          :disabled="detailDisabled"
        />
      </el-col>
      <el-col :span="6">
        <span class="large">{{ $t('market.safeStock') }}<!--安全库存--></span>
        <el-input
          v-model="information.fsafeStock"
          placeholder="请输入安全库存"
          size="mini"
          class="input-width"
          type="number"
          :disabled="detailDisabled"
        />
      </el-col>
      <el-col :span="6">
        <span class="large">{{ $t('market.maxStock') }}<!--最大库存--></span>
        <el-input
          v-model="information.fmaxStock"
          placeholder="请输入最大库存"
          size="mini"
          class="input-width"
          type="number"
          :disabled="detailDisabled"
        />
      </el-col>
    </el-row>
    <!--    仓库-->
    <selectCK v-if="openWarehouse" @client="warehouseSelectRow" />
  </div>
</template>

<script>
import autocomplete from '@/views/market/marketManage/createMarkerOrder/components/autocomplete'

export default {
  name: 'Index',
  components: {
    selectCK: () => import('@/views/production/collect/components/seleceCK')
  },
  mixins: [autocomplete],
  props: {
    unit: {
      type: Object,
      default: () => {
        return {}
      }
    },
    information: {
      type: Object,
      default: () => {
        return {}
      }
    },
    detailDisabled: {
      type: Boolean,
      default: false
    },
    detailShow: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      openWarehouse: false // 仓库弹窗
    }
  },
  watch: {
    unit(ev) {
      this.$set(this.information, 'fstoreUnitId', ev.fid)
      this.$set(this.information, 'fstoreUnit', ev.fname)
    }
  },
  methods: {
    // 双击仓库弹窗
    warehouseSelectRow(item) {
      const { fname, fstockId } = item
      this.information.fstockId = fstockId
      this.information.fstock = fname
      this.openWarehouse = false
    }
  }
}
</script>

<style scoped lang="scss">
.elRow {
  display: flex;
  flex-wrap: wrap;
  .large {
    width: 80px;
    font-size: 14px;
    color: #606266;
    line-height: 40px;
    padding: 0 12px 0 12px;
    font-weight: 700;
  }
  .warehouse::before {
    content: '*';
    padding-right: 2px;
    color: red;
  }
  .input-width {
    width: 185px;
  }
  .el-icon-search {
    cursor: pointer;
  }
}
.el-table ::v-deep .el-table__body-wrapper {
  height: 480px;
}
</style>
